<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
    <meta property="og:url" content="https://api.vvhan.com/" />
    <meta itemprop="image" content="/images/logo.webp" />
    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="../css/main.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/ashes.min.css" />
    <title>BMI Calculator</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 40px;
            padding: 0;
            background-color: #f0f0f0;
        }
        .container {
            background: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
            max-width: 400px;
            margin: 0 auto;
        }
        .container h1 {
            text-align: center;
            margin-bottom: 20px;
        }
        .container label {
            display: block;
            margin: 15px 0 5px;
        }
        .container input {
            width: 100%;
            padding: 8px;
            margin-bottom: 10px;
            border-radius: 4px;
            border: 1px solid #ccc;
        }
        .container button {
            width: 100%;
            padding: 10px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        .container button:hover {
            background-color: #0056b3;
        }
        .result {
            margin-top: 20px;
            font-size: 18px;
            text-align: center;
        }
    </style>
</head>

<body>
<img src="/images/logo.webp" alt="logo" style="display: none"/>
<section class="fixed-section">
    <canvas class="vh-bg"></canvas>
    <div class="vh_boy"></div>
</section>
<section class="page">
    <div class="container">
        <h1>BMI Calculator</h1>
        <form id="bmiForm">
            <label for="weight">Weight (kg):</label>
            <input type="number" id="weight" name="weight" required>

            <label for="height">Height (cm):</label>
            <input type="number" id="height" name="height" required>

            <button type="submit">Calculate BMI</button>
        </form>
        <div class="result" id="result"></div>
    </div>

    <script>
        document.getElementById('bmiForm').addEventListener('submit', function(event) {
            event.preventDefault(); // 防止表单提交

            const weight = document.getElementById('weight').value;
            const height = document.getElementById('height').value;

            fetch(`https://papi.v-box.cn/api/app/open-api/bmi?weight=${weight}&height=${height}`)
                .then(response => response.json())
                .then(data => {
                    const resultDiv = document.getElementById('result');
                    if (data && data.bmi) {
                        resultDiv.textContent = `Your BMI is ${data.bmi}`;
                    } else {
                        resultDiv.textContent = `Error: ${data.message}`;
                    }
                })
                .catch(error => {
                    document.getElementById('result').textContent = 'An error occurred. Please try again.';
                    console.error('Error:', error);
                });
        });
    </script>

    <svg class="vh-bolang" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
         viewBox="0 24 150 28" preserveAspectRatio="none">
        <defs>
            <path id="vh-bolang-item"
                  d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z"></path>
        </defs>
        <g class="vh-bolang-main">
            <use xlink:href="#vh-bolang-item" x="50" y="0" fill="rgba(224,233,239,.5)"></use>
            <use xlink:href="#vh-bolang-item" x="50" y="3" fill="rgba(224,233,239,.5)"></use>
            <use xlink:href="#vh-bolang-item" x="50" y="6" fill="rgba(224,233,239,.5)"></use>
        </g>
    </svg>
    <section class="ξvh-toast"></section>
    <script src="../js/main.min.js"></script>
    <script src="../js/jquery.min.js"></script>

    <!-- 子页面展示 -->
    <script src="../js/page.js"></script>
    <script src="../js/highlight.min.js"></script>
    <script>
        $(() => hljs.highlightAll());
    </script>

    <!-- 统计代码 -->
    <script charset="UTF-8" id="LA_COLLECT" src="https://sdk.51.la/js-sdk-pro.min.js"></script>
    <script>
        LA.init({id: "JLvourAu9qIUtWYT", ck: "JLvourAu9qIUtWYT"});
    </script>
</section>
</body>
</html>
